


$(document).ready(function(){

	LoadSortbyClass();

	$("#sort_view_count").click(
		function(){
			SetSortBy( "1" )
		}
	);
	
	$("#sort_create_time").click(
		function(){
			SetSortBy( "2" )
		}
	);
	
	$("#sort_response_count").click(
		function(){
			SetSortBy( "3" )
		}
	);
	
	$("#sort_flower_count").click(
		function(){
			SetSortBy( "4" )
		}
	);
		
});

function SetSortBy( type ){
	//reset the sort by selector
	
	$( "#s" ).val(type);
	$( "#sortform" ).submit();
}

function LoadSortbyClass(){

	var sortby = $( "#s" ).val();
  
	if( sortby == '1' ){
	
		$( "#sort_view_count" ).replaceWith('<span>'+$( "#sort_view_count" ).text()+'</span>');
	}

	if( sortby == '2'  ){
	
		$( "#sort_create_time" ).replaceWith('<span>'+$( "#sort_create_time" ).text()+'</span>');
	}

	if( sortby == '3'  ){
	
		$( "#sort_response_count" ).replaceWith('<span>'+$( "#sort_response_count" ).text()+'</span>');
	}
	
	if( sortby == '4'  ){
	
		$( "#sort_flower_count" ).replaceWith('<span>'+$( "#sort_flower_count" ).text()+'</span>');
	}
}


function del_list( listId, thisLink )
{
	MessageBox( "确定要删除评单吗？会扣除您的贡献值和E币!", '删除确认', 
			{yes : function() {send_del_list(listId, thisLink);},
			 no : function(){UnblockUI();} },
			 true );
}

function send_del_list( listId, thisLink )
{
	
    $.ajax(
  	{
  		type: 'get',
        url: edp_domain_url + 'del_list/?tiny=2',
        data: 'lid=' + listId,
		timeout: 5000,
		global:false,
	    beforeSend: function()
	    {
		},
		error: function()
		{
			alert("错误，稍后再试！");
		},
		success: function( data, textStatus )
        {
        	SimpleMessage( data, 3000 );
        	if( data.indexOf('成功') != -1 )
        		$(thisLink).closest("li").css('display', 'none');
        }
    });
}
